package magis;

import bankobjectsgui.*;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

/** Customer class.  General contact information and stores their accounts.  */
public class Customer {
    
    // Default Customer Name when we add new customers.
    public static final String DEFAULT_NAME = "Name";

    // Customer Variables
    private String number = "";
    private String name = "";
    private String address = "";
    private String city = "";
    private String state = "";
    private String zipCode = "";
    private String phone = ""; // Possibly add a phone formatter
    //private List<Account> accounts = new ArrayList<Account>();

    /**
     * Customer Constructor
     * @param number Customer's Number
     * @param name Customer Name
     * @param address Customer Address
     * @param city Customer's City
     * @param state Customer's State
     * @param zipCode Customer's Zip Code
     * @param phone Customer's Phone Number
     **/
    public Customer(String number, String name, String address, String city, String state, String zipCode, String phone) {
        this.setNumber(number);
        this.setName(name);
        this.setAddress(address);
        this.setCity(city);
        this.setState(state);
        this.setZipCode(zipCode);
        this.setPhone(phone);
    }

    /** Print each account number, type, balance, and interest rate  */
    public void printAccounts(PrintWriter out) {
        out.println("<h2>Accounts</h2>");
        for (Account account : this.getAccounts()) {
            account.printAccount(out);
        }//for account
    }

    /** Print Customer General Information	 */
    public void printGeneralInformation(PrintWriter out) {
        out.println("<h2>Customer Information</h2>");
        out.println("<ul>");
        out.println("<li>Customer Number: " + this.getNumber() + "</li>");
        out.println("<li>Name: " + this.getName() + "</li>");
        out.println("<li>Address: " + this.getAddress() + "</li>");
        out.println("<li>" + this.getCity() + ", " + this.getState() + " " + this.getZipCode() + "</li>");
        out.println("<li>Phone: " + this.getPhone() + "</li>");
        out.println("</ul>");
    }

    /** Print customer general information and account information  */
    public void printAllCustomerInformation(PrintWriter out) {
        printGeneralInformation(out);
        printAccounts(out);
        out.println("<hr />");
    }

    /** Getters / Setters */
    /** set customer number  */
    public void setNumber(String number) {
        this.number = number;
    }

    /** get customer number  */
    public String getNumber() {
        return number;
    }

    /** set customer name  */
    public void setName(String name) {
        this.name = name;
    }

    /** get customer name  */
    public String getName() {
        return name;
    }

    /** set customer address  */
    public void setAddress(String address) {
        this.address = address;
    }

    /** get customer address  */
    public String getAddress() {
        return address;
    }

    /** set customer city  */
    public void setCity(String city) {
        this.city = city;
    }

    /** get customer city  */
    public String getCity() {
        return city;
    }

    /** set customer state  */
    public void setState(String state) {
        this.state = state;
    }

    /** get customer state  */
    public String getState() {
        return state;
    }

    /** set customer zip code  */
    public void setZipCode(String zipCode) {
        this.zipCode = zipCode;
    }

    /** get customer zip code  */
    public String getZipCode() {
        return zipCode;
    }

    /** set customer phone  */
    public void setPhone(String phone) {
        this.phone = phone;
    }

    /** get customer phone  */
    public String getPhone() {
        return phone;
    }

    /** add customer account to accounts  */
    public void addAccount(Account account) {
        accounts.add(account);
    }

    /** add customer account to accounts  */
    public void removeAccount(Account account) {
        accounts.remove(account);
    }

    /** get customer accounts  */
    public List<Account> getAccounts() {
        return accounts;
    }
}
